package com.luo.controller;

import com.luo.pojo.User;
import com.luo.service.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping(value = "/selectUserList",method = RequestMethod.GET)
    public Map<String,Object> selectUserList(@RequestParam int page,
                                             @RequestParam int limit,
                                             String username ,
                                             String phone,
                                             String departmentId,
                                             String roleId){
        return userService.selectUserList(username,phone,departmentId,page,limit,roleId);
    }

    @RequestMapping(value = "/insert",method = RequestMethod.POST)
    public Map<String,Object> insert(@RequestBody User user){
        return userService.insert(user);
    }

    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    public Map<String,Object> delete(@RequestParam Integer id){
        return userService.delete(id);
    }

    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public Map<String,Object> update(@RequestBody  User user){
        return userService.update(user);
    }

    @RequestMapping(value = "/selectUsernames",method = RequestMethod.GET)
    public Map<String,Object> selectUsernames(){
        return userService.selectUsernames();
    }
}
